#!/bin/bash

SKEL=../../../../share/bisonc++
BISONCPP="../../../../tmp/bin/bisonc++ -B ${SKEL}base.h -C ${SKEL}.h -I ${SKEL}.ih -P ${SKEL}.cc"

[ -e grammar ] || cd parser

if [ ! -e grammar ] 
then
    echo "The file grammar must be in the current directory or in the parser 
subdirectory"
    exit 1
fi

$BISONCPP grammar

cd ../scanner
flex -I lexer

if [ $# == 0 ]
then
    echo "any argument will compile the parser to \`demo'"
else
    cd ..
    g++ -Wall -o demo *.cc */*.cc
fi

